package week08.day01;
/*
 * 向上转型：子类对象当作父类对象来引用
 */
public class 向下转型 {
    public static void main(String[] args) {
        Fruit01 fruit1 = new Apple01();
        Apple01 apple01 = (Apple01) fruit1;//向下转型
        Banana banana = new Banana();
        banana.eat();
        fruit1.eat();
    }
}

class Fruit01 {
    String name;
    public void eat(){
        System.out.println("吃水果补充维生素");
    }
}

class Apple01 extends Fruit01{
    public void eat(){
        System.out.println("吃苹果");
    }
}

class Banana extends Fruit01{
    @Override
    public void eat() {
        System.out.println("吃香蕉有助于消化");
    }
}